package org.example.factory.simple.order;

import org.example.factory.simple.pizzastore.CheesePizza;
import org.example.factory.simple.pizzastore.GreekPizza;
import org.example.factory.simple.pizzastore.PepperPizza;
import org.example.factory.simple.pizzastore.Pizza;
import org.springframework.stereotype.Component;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author
 * @description 订单产品入口
 */
@Component
public class OrderPizza {
    public OrderPizza() {
        Pizza pizza = null;
        String orderType;
        do {
            orderType = getType();
            if (orderType.equals("greek")) {
                pizza = new GreekPizza();
                pizza.setName("希腊披萨");
            } else if (orderType.equals("cheese")) {
                pizza = new CheesePizza();
                pizza.setName("奶酪披萨");
            } else if (orderType.equals("pepper")) {
                pizza = new PepperPizza();
                pizza.setName("胡椒披萨");
            }else {
                break;
            }
            //若想知道不同披萨的制作过程
            pizza.prepare();
            pizza.bake();
            pizza.cut();
            pizza.box();
            System.out.println("----------------------------------------");
        } while (true);
    }

    //写一个方法，获取客户希望订购的披萨种类
    private String getType() {
        try {
            BufferedReader strin =
                    new BufferedReader(new InputStreamReader(System.in));
            System.out.println("请输入Pizza类型:");
            return strin.readLine();
        } catch (IOException e) {
            e.printStackTrace();
            return "";
        }
    }
}
